# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo06
# Description:
# Author:       98745
# Date:         2019/3/3
#-------------------------------------------------------------------------------

class N(Exception):
    pass
class Z(Exception):
    pass
class S:
    def add(self,x,y):
        if x<0 or y<0:
            raise N('x和y 都不能小于0')
        return x+y
    def sub(self,x,y):
        if x-y<0:
            raise N('x与y的差值不能小于0')
        return x-y
    def mul(self,x,y):
        if x==0 or y==0:
            raise  Z('x和y都不能等于0')
        return x*y
    def div(self,x,y):
        return x/y

while True:
    try:
        c=S()
        e=input('请输入要计算的表达式，例如，add(1,2):')
        if e=='exit':
            break
        re=eval('c.'+e)
        print('计算结果：{:.2f}'.format(re))
    except N as e:
        print(e)
    except Z:
        print(e)
    except ZeroDivisionError:
        print(e)
    except:
        print('***其他异常***')